<?php
/**
 * Created by PhpStorm.
 * User: XD
 * Date: 2017/10/27
 * Time: 10:48
 */
namespace App\Http\Controllers\File;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use SebastianBergmann\CodeCoverage\Report\PHP;

class FileController extends Controller
 {

     //文件上传方法
     public function upload(Request $request)
     {
         \Log::info("mupload join upload function ");
         if($request ->isMethod('POST')){
             $file = $request->file('source');
             \Log::info("mupload getfile success");
             //判断文件是否上传成功
             if($file->isValid()){
                 \Log::info("mupload file up To complete success");
                 //获取原文件名
                 $originalName = $file ->getClientOriginalName();
                 //扩展名
                 $ext = $file -> getClientOriginalExtension();
                 //文件类型
                 $type = $file->getClientMimeType();
                 //临时绝对路径
                 $realPath = $file->getRealPath();

                 \Log::info("mupload get realPath: ".$realPath);

                 $filename = date('Y-m-dTH:i:sZ',time()).'-'.uniqid().'-'.$ext;


//                 $bool = $file->store('avatars');
                 $file->storeAs("/app/email/Template/attachement/",'one.txt');
//                 $bool = \Storage::disk('uploads')->put($filename,  file_get_contents($realPath),'public');

//                 var_dump($bool);

             }
             \Log::info("mupload at if outside  success");
             exit;
         }
         return view('file.upload');
//         return "test";
     }

 }
